<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>transition组件</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        .box {
            width: 100%;
            height: 10%;
            text-align: center;
            line-height: 200px;
            background-color: #ff8282;
            color: #ffffff;

            opacity: 1;
            margin-left: 0;
        }

        .box-enter-active,
        .box-leave-active {
            transition: all .8s;
        }

        .box-enter {
            opacity: 0;
            margin-left: 100%;
        }

        .box-leave-active {
            opacity: 0;
            margin-left: 100%;
        }
    </style>
</head>

<body>
    <div id="app">
        <button class="btn" @click="changeStatus()">切换</button>
        <div class="container">
            <transition name="box">
                <div v-if="showBox" class="box">
                    I am a box
                </div>
            </transition>
        </div>
    </div>
    <script>
        let app = new Vue({
            el: '#app',
            data: {
                showBox: false
            },
            methods: {
                changeStatus: function () {
                    console.log(this.showBox)
                    this.showBox = !this.showBox
                }
                // changeStatus() {
                //     console.log(this.$data.showBox)
                //     this.$data.showBox = !this.$data.showBox
                // }
            }
        })
    </script>
</body>

</html>